#include <iostream>

using namespace std;
class Figure
{
public:
    Figure(){
        cout << "Figure()" << endl;
    }
    ~Figure(){
        cout << "~FIgure()" << endl;
    }
    virtual double area(){
        return 0;
    }
private:
};

class circle
:public Figure
{
public:
    circle(double r)
    :_r(r)
    {
        cout << "circle(double)" << endl;
    }
    ~circle(){
        cout << "circle()" << endl;
    }
    double area() override{
        return 3.14 * _r * _r;
    }
private:
    double _r;
};

class rectangle
:public Figure
{
public:
    rectangle(double a, double b)
    :_width(a)
    ,_length(b)
    {
        cout << "rectangle(double, double)" << endl;
    }
    ~rectangle(){
        cout << "~rectangle()" << endl;
    }
    double area() override {
        return _width * _length;
    }
private:
    double _width;
    double _length;
};

class triangle
:public Figure
{
public:
    triangle(double length, double width) 
    :_length(length)
    ,_width(width)
    {
        cout << "triangle(double, double)" << endl;
    }
    ~triangle(){
        cout << "~triangle()" << endl;
    }
    double area() override{
        return _length * _width / 2.0;
    }
private:
    double _length;
    double _width;
};

int main(int argc, char const *argv[])
{
    circle c1(2);
    cout << c1.area() << endl;

    rectangle r1(3, 4);
    cout << r1.area() << endl;
    
    triangle t1(3, 4);
    cout << t1.area() << endl;

    return 0;
}
